/**
 * 房屋出租审核管理初始化
 */
var HouseRentCheck = {
    id: "HouseRentCheckTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
HouseRentCheck.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: 'id', field: 'id', align: 'center', valign: 'middle',width:'50px'},
        {title: '标题', field: 'house_title', align: 'center', valign: 'middle', sortable: true},
        {title: '申请人', field: 'owner_name', align: 'center', valign: 'middle', sortable: true},
        {title: '发布日期', field: 'publish_date', align: 'center', valign: 'middle', sortable: true}];
};

/**
 * 检查是否选中
 */
HouseRentCheck.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if (selected.length == 0) {
        Feng.info("请先选中表格中的某一记录！");
        return false;
    } else {
        HouseRentCheck.seItem = selected[0];
        return true;
    }
};


/**
 * 点击审核按钮时
 * @param userId 管理员id
 */
HouseRentCheck.openHouseCheck = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '房源出租申请审核',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/houserentcheck/view/' + this.seItem.id
        });
        this.layerIndex = index;
    }
};

HouseRentCheck.resetSearch = function () {
    $("#title").val("");
    $("#beginTime").val("");
    $("#endTime").val("");

    HouseRentCheck.search();
}

HouseRentCheck.search = function () {
    var queryData = {};

    queryData['title'] = $("#title").val();
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();

     HouseRentCheck.table.refresh({query: queryData});
}

$(function () {
     var defaultColunms = HouseRentCheck.initColumn();
        var table = new BSTable("HouseRentCheckTable", "/houserentcheck/list", defaultColunms);
        table.setPaginationType("client");
        HouseRentCheck.table = table.init();
});
